unit base.database.conexao;

interface

uses
  SqlExpr;

type
  TConexao = class(TObject)
  private
    fConexao: TSQLConnection;
    function getConexao: TSQLConnection;
  public
    property Conexao: TSQLConnection  read getConexao;
    function Conectar(BasedeDados: String): boolean;

    constructor Create; overload;
    destructor Destroy; override;
  end;

implementation

{ TConexao }

function TConexao.Conectar(BasedeDados: String): boolean;
begin
  Conexao.ConnectionName := 'ConexaoPrincipal';
  Conexao.DriverName := 'Interbase';
  Conexao.GetDriverFunc
end;

constructor TConexao.Create;
begin
  inherited;

end;

destructor TConexao.Destroy;
begin
  if Assigned(fConexao) then
  begin
    fConexao.Close();
    FreeAndNil(fConexao);
  end;

  inherited;
end;

function TConexao.getConexao: TSQLConnection;
begin
  if not assigned(fConexao) then
    fConexao := TSQLConnection.Create(nil);

  result := fConexao;
end;

end.
 